//mainStore存储的数据一般是共享给多个页面的。
import {
    defineStore
} from "pinia";
import {
    getInfo
} from '@/api/manager'
import { removeToken } from "@/composible/cookie";
const usemainStore = defineStore("mainStore", {
    state: () => {
        return {
            userInfo: "",
            SiderLength: "250px",
            menus: [],
            ruleNames:[]
        }
    },
    actions: {
        getUser() {
            getInfo().then(res => {
                this.userInfo = res;
                this.menus = res.menus;
                this.ruleNames = res.ruleNames;
                // console.log(this.userInfo);
            })
        },
        logout()
        {
            //清除token
            removeToken();
            //清除state
            this.userInfo = "";
        },
        
    },
   persist: true,
  
});

export {
    usemainStore
};